Macromedia Flex Article

Learning Flex Basics (Part 1): Creating Your First Flex Application


Table of Contents

  1. Introduction
  2. A Brief Overview of Macromedia Flex
  3. Building the Application
  4. Create the Application Object
  5. Add a Panel for the Application Layout
  6. Add a Label for the View Header
  7. Add an Array of Objects to Define the Coffee Blends
  8. Add a ComboBox to Display the Coffee Blends
  9. Add a Text Control to Display the Description
  10. Add a Button to Add a Coffee Blend to the Shopping Cart
  11. Add a List Control for the Shopping Cart
  12. Add a Script to Handle the Button Click Event
  13. Complete Code Listing for firstapp.mxml
  14. Where to Go From Here

Add a Button to Add a Coffee Blend to the Shopping Cart

The Button control is straightforward. It has a label property for the text label to display. It also has a click event set equal to an ActionScript expression or event-handler that will execute when the user clicks the button.

In this case, you add a Button that adds the selected item in the ComboBox to a simple cart by using the click event to call a function called addToCart(). You create this function and the cart in later steps.

  1. After the Text control, add a Button with a label that says "Add to Cart" and click event that calls an addToCart() function:

    <mx:Button label="Add to Cart" click="addToCart()"/>